import QtQuick 2.0
import QtQuick.Controls 2.14
import Mydata 1.0
//开关控制模块
Item {
    id: sbkzItem
    anchors.fill: parent
    Image {//设备控制
        id: sb
        anchors.fill: parent
        source: "/shebeikz.bmp"
        MouseArea {//返回
            x: 0
            y: 0
            width: 90
            height: 80
            onClicked: {
                rootLoader.source = "Zhujiemian.qml"
                winroot.myindex = 1

            }
        }
    }

    ListView {//开关模块
        id: listView
        x:120
        y:100
        width:400
        height: 400
        model: ["灯光控制","加湿器控制","加热器控制","通风设备控制"]
        spacing: 10
        highlight: Rectangle {
            id: rect1
            color: "grey"
            opacity: 0.3
        }
        delegate:  Rectangle {
            id: znkzrec
            radius: 10
            color: "#1d3cc3"
            width: 400
            height: 60
            Text {
                id: text
                text: modelData
                color: "red"
                anchors.left: parent.left
                anchors.leftMargin: 10
                font.pixelSize: 30
                anchors.verticalCenter: parent.verticalCenter
            }
            Switch {
                id: switc
                anchors.right: parent.right
                anchors.rightMargin: 10
                anchors.verticalCenter: parent.verticalCenter
                checked: winroot.boolshebei[index]
                onCheckedChanged: {
                    if (switc.checked) {
                        winroot.boolshebei[index] = true;
                    } else {
                        winroot.boolshebei[index] = false;
                    }
                    rootdata.my_send(2,winroot.boolshebei[0],winroot.boolshebei[1],winroot.boolshebei[2],winroot.boolshebei[3])
                }
            }
        }
    }
}
